package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Goods;
import com.atguigu.jxc.service.GoodsService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @RequestMapping("/listInventory")
    public Map<String,Object> listInventory(Integer page, Integer rows, String codeOrName, Integer goodsTypeId){
        return goodsService.listInventory(page,rows,codeOrName,goodsTypeId);
    }

    /**
     * 请求URL：http://localhost:8080/goods/list
     * 请求参数：Integer page, Integer rows, String goodsName, Integer goodsTypeId
     * 请求方式：POST
     * 返回值类型：JSON
     * 返回值：Map<String,Object>
     */
    @PostMapping("/list")
    public Map list(Integer page, Integer rows, String goodsName, Integer goodsTypeId){
        return goodsService.list(page,rows,goodsName,goodsTypeId);
    }

    /**
     * 请求URL：http://localhost:8080/goods/save?goodsId=37
     * 请求参数：Goods goods
     * 请求方式：POST
     * 返回值类型：JSON
     * 返回值：ServiceVO
     * 11111111111111111111111111111111111111111111111
     */
    @PostMapping("/save")
    public ServiceVO save(Goods goods){
        return goodsService.save(goods);
    }
}
